package com.tehui.app;

import android.app.Application;
import android.content.Context;
import android.os.Handler;
import android.os.Process;

import com.lzy.okgo.OkGo;
import com.orhanobut.logger.AndroidLogAdapter;
import com.orhanobut.logger.Logger;
import com.tendcloud.tenddata.TCAgent;

/**
 * Created by jasmine on 2017/2/28.
 */

public class MyApplication extends Application {

    public static Context applicationContext;
    public static Handler handler;
    public static int     mainThreadId;
    public static final String WX_APPID      = "wxfe00130e495bb735";
    public static final String WX_APP_SECRET = "21817292548ebce40100adc5b0b8e910";

    //是否是淘客app
    public static final boolean IS_TAOKE = false;

    @Override
    public void onCreate() {
        super.onCreate();
        OkGo.init(this);

        Logger.addLogAdapter(new AndroidLogAdapter());

        //捕获全局异常
        getAnyException();

        initGlide();

        //初始化全局context
        applicationContext = getApplicationContext();

        //创建主线程Handler
        handler = new Handler();

        //返回调用此方法的线程id
        mainThreadId = Process.myTid();
        InitializeService.start(this);

        //talkingData统计
        TCAgent.LOG_ON = false;
        TCAgent.init(this);
        TCAgent.setReportUncaughtExceptions(false);
    }

    private void initGlide() {
    }

    protected void attachBaseContext(Context base) {
        super.attachBaseContext(base);
        //        MultiDex.install(this);
    }

    private void getAnyException() {
        Thread.setDefaultUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() {
            @Override
            public void uncaughtException(Thread t, Throwable e) {
                e.printStackTrace();
                System.exit(0);
            }
        });
    }


}
